
// import { list , reminder} from '../../../api/point'
import { list } from '../../../../api/stockRight'
const util = require('../../../../utils/util.js')

const app = getApp()
Page({
    data: {
        pageNum: 1,
        pageSize: 20,
        detailedList: [],
        type:""
    },
    onLoad (options) {
        this.data.type = options.type
        this.setData({
            type: this.data.type
        })
    },
    onShow () {
        this.data.pageNum=1,
        this.data.pageSize=20,
        this.loadList()
    },
    loadList() {
        if (this.data.pageNum == 1) {
            this.data.detailedList = []
        }
        list({
            pageSize: this.data.pageSize,
            pageNum: this.data.pageNum,
            type:this.data.type
        }).then(res => {
            res.data.data.forEach(item => {
                item.createDate = util.datetimeFormat(item.createDate)
                item.thumbnail = 'https://cdn.rzico.com/v4.0/wallet-consumption.png'
                let credit = item.credit;
                item.credit = credit.toFixed(2)
                let debit = item.debit ;
                item.debit = debit.toFixed(2)
                let balance = item.balance
                item.balance = balance.toFixed(2)
                this.data.detailedList.push(item)
            })
            this.setData({
                detailedList: this.data.detailedList
            })
        })

    },
    onPullDownRefresh() {
        wx.showNavigationBarLoading()
        this.data.pageNum = 1
        setTimeout(() => {
            wx.hideNavigationBarLoading()
            this.loadList()
            wx.stopPullDownRefresh()
        }, 1000);
    },
    onReachBottom() {
        this.data.pageNum += 1
        this.loadList()
    },
})
